#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 10
typedef int ElemType;
typedef struct SSTable {
    ElemType lenth;
    ElemType *str;
} SSTable;

void SST_Init(SSTable &T, int len) {
    T.lenth = len;
    T.str = (ElemType *) malloc(sizeof(ElemType) * T.lenth);
//    srand(time(NULL));
    for (int i = 0; i < T.lenth; i++) {
        int num;
        scanf("%d", &num);
        T.str[i] = num;
    }
//    int a[N] = {3, 87, 2, 93, 78, 56, 61};
//    memcpy(T.str, a, sizeof(a));
}

void swap(int &a, int &b) {
    a ^= b;
    b ^= a;
    a ^= b;
}

void array_print(SSTable T) {
    for (int i = 0; i < T.lenth; i++) {
        printf("%3d", T.str[i]);
    }
    printf("\n");
}

void array_print_str(ElemType *str, ElemType len) {
    for (int i = 0; i < len; i++) {
        printf("%3d", str[i]);
    }
    printf("\n");
}

void Merge(ElemType *str, int low, int mid, int high) {
    static ElemType arr[N];
    int i, j, k;
    for (i = low; i <= high; i++) {
        arr[i] = str[i];
    }
    k = low;
    for (i = low, j = mid + 1; i <= mid && j <= high;) {
        if (arr[i] < arr[j]) {
            str[k++] = arr[i++];
        } else {
            str[k++] = arr[j++];
        }
    }
    while (i <= mid) {
        str[k++] = arr[i++];
    }
    while (j <= high) {
        str[k++] = arr[j++];
    }
}

void MergeSort(ElemType *str, int low, int high) {
    if (low < high) {
        //分
        int mid = (low + high) / 2;
        MergeSort(str, low, mid);
        MergeSort(str, mid + 1, high);
        //合
        Merge(str, low, mid, high);
    }
}
int main() {
    SSTable T;
    SST_Init(T, N);
    MergeSort(T.str, 0, N);
    array_print(T);

    return 0;
}
